﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Model.WaiGaoQiao;
using WaiGaoQiaoWeb.JsonEntities;
using System.Web.Script.Serialization;
using WaiGaoQiaoWeb.FilterSession;
using WaiGaoQiaoWeb.Models;

namespace WaiGaoQiaoWeb.Controllers
{

    [WaiGaoQiaoWeb.FilterSession.AuthorizeAttribute]
    public class BaseController : Controller
    {
        //
        // GET: /Base/

        public ActionResult Index()
        {
            return View();
        }



        public ActionResult LamDa_A()
        {
            int[] numbers = { 5, 10, 8, 3, 6, 12 };

            //Query syntax:
            IEnumerable<int> numQuery1 =
                from num in numbers
                where num % 2 == 0
                orderby num
                select num;

            IEnumerable<int> numQuery2 = numbers.Where(num => num % 2 == 0).OrderBy(num => num);

            int nmax = numbers.Max();

            var shortDigits = nmax;
            return Json(shortDigits);
        }

        public JavaScriptResult UserData()
        {
            //MenuInfo menu = new MenuInfo();
            //List<MenuInfo> list = menu.GetMenuBy();
            //JavaScriptSerializer s = new JavaScriptSerializer();
            //StringBuilder sb = new StringBuilder();
            //s.Serialize(list, sb);
            //sb.Insert(0, "Rows:");
            //string sb1 = "var userdata = ";
            //sb1 = sb1 + sb.ToString();
            return JavaScript("");
        }

        //public List<UserInfo> GetUser()
        //{            
        //    //DataAccessUser dau = new DataAccessUser();
        //    List<UserInfo> ulist = null;//dau.DA_GetUser();
        //    return ulist;
        //}

        public ActionResult GetSel(PageVM pvm)
        {
            //DataAccessUser dau = new DataAccessUser();
            //IList<UserInfo> ulist = dau.GetUserName("and UserLogName = 'User01'", pvm.rp,pvm.page); //GetSqlStatements.GetSelect("select_usercount",null);

            //JsonFlexiGridData jfgd = new JsonFlexiGridData();
            //jfgd.page = pvm.page;
            //jfgd.total = 30;
            //List<string> v;
            //foreach (UserInfo tinfo in ulist)
            //{
            //    #region
            //    v = new List<string>();
            //    v.Add(tinfo.UserLogName.ToString());
            //    v.Add(tinfo.UserName.ToString());
            //    v.Add(tinfo.QuanXian.ToString());
            //    #endregion
            //    FlexiGridRow fgr = new FlexiGridRow()
            //    {
            //        id = tinfo.UserLogName.ToString(),
            //        cell = v
            //    };
            //    jfgd.rows.Add(fgr);
            //}
            return Json("jfgd");
        }

        public ActionResult GetUserName()
        {
            //DataAccessUser dau = new DataAccessUser();
            //IList<UserInfo> ulist = dau.GetUserName("and UserLogName = 'User01'");
            //Hashtable ht = new Hashtable();
            //UserInfo uinfo = new UserInfo() {  UserName="ABB", UserLogName = "张丰毅", 
            //                                   QuanXian = "FAS", CreateDt = Convert.ToDateTime("2011-11-08")};
            //ht["uinfo"] = uinfo;

            //int fullname = dau.SaveUser(uinfo); //GetSqlStatements.ExeInsert("insert_user", ht);
            return Json("fullname");            
        }

        public ActionResult AddUser()
        {
            return View();
        }

    }
}
